package com.util;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HandleInfo
{
	public static void handle(HttpServletRequest request,
			HttpServletResponse response, String errorInfo)
	{
		/*
		 * forward to handle error page
		 */
		try
		{
			request.getRequestDispatcher("/error.jsp?errorInfo=" + errorInfo)
					.forward(request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public static void ajax(HttpServletResponse response, String info)
	{
		try
		{
			response.setContentType("text/html");
			Writer w = response.getWriter();
			w.write(info);
			w.flush();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
